package com.danco.training.zaneuskaya.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Zaneuskaya Aliaksandra
 *
 */
@Entity
@Table(name = "note")
public class Note implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8720360685036412238L;

	@Id
	@GeneratedValue
	@Column(name = "note_id")
	private Integer noteId;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "note_sender_fk", referencedColumnName = "user_id")
	private User noteSender;

	@Column(name = "note_text")
	private String noteText;

	@Column(name = "note_time")
	@Temporal(value = TemporalType.TIMESTAMP)
	private Date noteTime;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "forum_fk", referencedColumnName = "forum_id")
	private Forum forum;

	public Integer getNoteId() {
		return noteId;
	}

	public void setNoteId(Integer noteId) {
		this.noteId = noteId;
	}

	public User getNoteSender() {
		return noteSender;
	}

	public void setNoteSender(User noteSender) {
		this.noteSender = noteSender;
	}

	public String getNoteText() {
		return noteText;
	}

	public void setNoteText(String noteText) {
		this.noteText = noteText;
	}

	public Date getNoteTime() {
		return noteTime;
	}

	public void setNoteTime(Date noteTime) {
		this.noteTime = noteTime;
	}

	public Forum getForum() {
		return forum;
	}

	public void setForum(Forum forum) {
		this.forum = forum;
	}

	@Override
	public int hashCode() {
		return getNoteId();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Note) {
			Note other = (Note) obj;
			return other.getNoteId() == noteId;
		}
		return false;
	}

}
